package com.paper.tiger.easy.rpc.s.client.execute;

import com.alibaba.fastjson.JSON;
import com.paper.tiger.easy.rpc.s.client.client.ContextManager;
import com.paper.tiger.easy.rpc.s.client.common.Dove;
import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * [简要描述]: 通道消息处理
 * [详细描述]: 客户端第一次启动成功，给服务器发送通道消息，服务器缓存客户端的ip-port，
 *
 *
 * @author ZouHaiBo
 * @version 1.0, 2021/6/17 19:48
 * @since JDK 1.8
 */
public class ChanelFlyDove implements FlyDove
{

    private static Logger logger = LoggerFactory.getLogger(ChanelFlyDove.class);

    @Override
    public void service(Dove dove, ChannelHandlerContext ctx)
    {

        logger.info("收到通道缓存消息，消息内容为：{}", JSON.toJSONString(dove));
        ContextManager.getInstance().addServerChannel(dove.getServiceName(),dove.getIp(),dove.getPort(),ctx.channel());

    }
}
